package com.ymatou.iapi.quickturnover.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.quickturnover.parameter.GetCancelOrdersRateReqBean;
import com.ymatou.iapi.quickturnover.service.GetCancelOrdersRateReqCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;
/**
*获取买手订单取消率信息接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetCancelOrdersRateReq{
	private static GetCancelOrdersRateReqBean getcancelordersratereqBean;
	private static GetCancelOrdersRateReqCall getcancelordersratereqCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取买手订单取消率信息接口");
	}

	@Before
	public void caseUp() {
		getcancelordersratereqBean=new GetCancelOrdersRateReqBean();
		getcancelordersratereqCall=new GetCancelOrdersRateReqCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getcancelordersratereqCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCancelOrdersRateReq_001() {
		Logger.start(true,"获取买手订单取消率信息");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			getcancelordersratereqBean.setSellerId(sellerId);
			getcancelordersratereqCall.setData(getcancelordersratereqBean);
			getcancelordersratereqCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, getcancelordersratereqCall.getString("code"), "验证code");
			Logger.verifyEquals(true, getcancelordersratereqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCancelOrdersRateReq_002() {
		Logger.start(true,"seller id 不存在");
		try {
			int sellerId = 1;
			getcancelordersratereqBean.setSellerId(sellerId);
			getcancelordersratereqCall.setData(getcancelordersratereqBean);
			getcancelordersratereqCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, getcancelordersratereqCall.getString("code"), "验证code");
			Logger.verifyEquals(true, getcancelordersratereqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCancelOrdersRateReq_003() {
		Logger.start(true,"seller id 为null");
		try {
			//getcancelordersratereqBean.setSellerId(sellerId);
			getcancelordersratereqCall.setData(getcancelordersratereqBean);
			getcancelordersratereqCall.callService();			
			Logger.verifyEquals(ECode.ERROR400, getcancelordersratereqCall.getString("code"), "验证code");
			Logger.verifyEquals("sellerId:卖家ID不能为0", getcancelordersratereqCall.getString("msg"), "验证code");
			Logger.verifyEquals(false, getcancelordersratereqCall.getData().getBoolean("success"), "验证success");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}